import request from '../utils/request'
export const todoGet = ()=>{ 
  return request.get('/classes/Todo')
}

export const todoPost = (taskObj)=>{  //新增
  return request.post('/classes/Todo',taskObj)
}

export const todoPut = (objectId,taskObj)=>{  //更新
  return request.put(`/classes/Todo/${objectId}`,taskObj)
}

export const todoDel = (objectId)=>{  //删除
  return request.delete(`/classes/Todo/${objectId}`)
}

export const todoBatchCheck = (allCheck,todolist)=>{  //数据库全选
  // {
  //   "requests": [
  //     {
  //       "method": "PUT",
  //       "path": `/1.1/classes/Todo/${objectId}`,
  //       "body": {
  //         "ischeck":true 
  //       }
  //     }
  //   ]
  // }
  let requests = todolist.map(item=>{
    return {
      "method": "PUT",
      "path": `/1.1/classes/Todo/${item.objectId}`,
      "body": {
        "ischeck":!allCheck   //allCheck时原来的全选状态
      }
    }
  })
  return request.post('/batch',{requests})
}